CFLAGS = -Wall -fpic -coverage -lm

rngs.o: rngs.h rngs.c
	gcc -c rngs.c -g  $(CFLAGS)

dominion.o: dominion.h dominion.c rngs.o
	gcc -c dominion.c -g  $(CFLAGS)

playdom: dominion.o playdom.c
	gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)

testDrawCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

badTestDrawCard: badTestDrawCard.c dominion.o rngs.o
	gcc -o badTestDrawCard -g  badTestDrawCard.c dominion.o rngs.o $(CFLAGS)

testBuyCard: testBuyCard.c dominion.o rngs.o
	gcc -o testBuyCard -g  testBuyCard.c dominion.o rngs.o $(CFLAGS)

unittestresults.out: unittest1.c unittest2.c unittest3.c unittest4.c cardtest1.c cardtest2.c cardtest3.c cardtest4.c dominion.o rngs.o
	echo "Results of unit tests on dominion.c:" > unittestresults.out
	echo " " >> unittestresults.out
	echo "unittest1.c:" >> unittestresults.out
	gcc -O0 -o unittest1 -g unittest1.c dominion.o rngs.o $(CFLAGS)
	unittest1 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda
	
	echo " " >> unittestresults.out
	echo "unittest2.c:" >> unittestresults.out
	gcc -O0 -o unittest2 -g unittest2.c dominion.o rngs.o $(CFLAGS)
	unittest2 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda
	
	echo " " >> unittestresults.out
	echo "unittest3.c:" >> unittestresults.out
	gcc -O0 -o unittest3 -g unittest3.c dominion.o rngs.o $(CFLAGS)
	unittest3 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda
	
	echo " " >> unittestresults.out
	echo "unittest4.c:" >> unittestresults.out
	gcc -O0 -o unittest4 -g unittest4.c dominion.o rngs.o $(CFLAGS)
	unittest4 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda
	
	echo " " >> unittestresults.out
	echo "cardtest1.c:" >> unittestresults.out
	gcc -O0 -o cardtest1 -g cardtest1.c dominion.o rngs.o $(CFLAGS)
	cardtest1 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda
	
	echo " " >> unittestresults.out
	echo "cardtest2.c:" >> unittestresults.out
	gcc -O0 -o cardtest2 -g cardtest2.c dominion.o rngs.o $(CFLAGS)
	cardtest2 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda
	
	echo " " >> unittestresults.out
	echo "cardtest3.c:" >> unittestresults.out
	gcc -O0 -o cardtest3 -g cardtest3.c dominion.o rngs.o $(CFLAGS)
	cardtest3 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda
	
	echo " " >> unittestresults.out
	echo "cardtest4.c:" >> unittestresults.out
	gcc -O0 -o cardtest4 -g cardtest4.c dominion.o rngs.o $(CFLAGS)
	cardtest4 >> unittestresults.out
	gcov -b dominion.c >> unittestresults.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda
	
randomtestcard.out: randomtestcard.c dominion.o rngs.o
	echo "Results of random tests on village card in dominion.c:" > randomtestcard.out
	echo " " >> randomtestcard.out
	gcc -O0 -o randomtestcard -g randomtestcard.c dominion.o rngs.o $(CFLAGS)
	randomtestcard >> randomtestcard.out
	gcov -b dominion.c >> randomtestcard.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda
	
randomtestadventurer.out: randomtestadventurer.c dominion.o rngs.o
	echo "Results of random tests on adventurer card in dominion.c:" > randomtestadventurer.out
	echo " " >> randomtestadventurer.out
	gcc -O0 -o randomtestadventurer -g randomtestadventurer.c dominion.o rngs.o $(CFLAGS)
	randomtestadventurer >> randomtestadventurer.out
	gcov -b dominion.c >> randomtestadventurer.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda
	
testScoreFor.out: testScoreFor.c dominion.o rngs.o
	echo "Results of testing scoreFor() in dominion.c:" > testScoreFor.out
	echo " " >> testScoreFor.out
	gcc -O0 -o testScoreFor -g testScoreFor.c dominion.o rngs.o $(CFLAGS)
	testScoreFor >> testScoreFor.out
	gcov -b dominion.c >> testScoreFor.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda
	
testIsGameOver.out: testIsGameOver.c dominion.o rngs.o
	echo "Results of testing isGameOver() in dominion.c:" > testIsGameOver.out
	echo " " >> testIsGameOver.out
	gcc -O0 -o testIsGameOver -g testIsGameOver.c dominion.o rngs.o $(CFLAGS)
	testIsGameOver >> testIsGameOver.out
	gcov -b dominion.c >> testIsGameOver.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda
	
testWhoseTurn.out: testWhoseTurn.c dominion.o rngs.o
	echo "Results of testing whoseTurn() in dominion.c:" > testWhoseTurn.out
	echo " " >> testWhoseTurn.out
	gcc -O0 -o testWhoseTurn -g testWhoseTurn.c dominion.o rngs.o $(CFLAGS)
	testWhoseTurn >> testWhoseTurn.out
	gcov -b dominion.c >> testWhoseTurn.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda
	
testGetWinners.out: testGetWinners.c dominion.o rngs.o
	echo "Results of testing whoseTurn() in dominion.c:" > testGetWinners.out
	echo " " >> testGetWinners.out
	gcc -O0 -o testGetWinners -g testGetWinners.c dominion.o rngs.o $(CFLAGS)
	testGetWinners >> testGetWinners.out
	gcov -b dominion.c >> testGetWinners.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda
	
testFindTheWinnerIntegration.out: testFindTheWinnerIntegration.c dominion.o rngs.o
	echo "Results of testing whoseTurn() in dominion.c:" > testFindTheWinnerIntegration.out
	echo " " >> testFindTheWinnerIntegration.out
	gcc -O0 -o testFindTheWinnerIntegration -g testFindTheWinnerIntegration.c dominion.o rngs.o $(CFLAGS)
	testFindTheWinnerIntegration >> testFindTheWinnerIntegration.out
	gcov -b dominion.c >> testFindTheWinnerIntegration.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda
	
testInitializeGame.out: testInitializeGame.c dominion.o rngs.o
	echo "Results of testing initializeGame() in dominion.c:" > testInitializeGame.out
	echo " " >> testInitializeGame.out
	gcc -O0 -o testInitializeGame -g testInitializeGame.c dominion.o rngs.o $(CFLAGS)
	testInitializeGame >> testInitializeGame.out
	gcov -b dominion.c >> testInitializeGame.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda
	
testSystem.out: testSystem.c dominion.o rngs.o interface.o
	echo "Results of testing complete games of dominion" > testSystem.out
	echo "A complete record of the history of the gamestate while running testdominion.c" > testSystemGameResults.out
	echo " " 2>> testSystem.out
	echo " " 1>> testSystemGameResults.out
	gcc -O0 -o testSystem testSystem.c -g  dominion.o rngs.o interface.o $(CFLAGS)
	testSystem 2>> testSystem.out 1>> testSystemGameResults.out
	gcov -b dominion.c 2>> testSystem.out
	#rm -f dominion.c.gcov
	#rm -f dominion.gcda

testAll: dominion.o testSuite.c
	gcc -o testSuite testSuite.c -g  dominion.o rngs.o $(CFLAGS)

interface.o: interface.h interface.c
	gcc -c interface.c -g  $(CFLAGS)

player: player.c interface.o
	gcc -o player player.c -g  dominion.o rngs.o interface.o $(CFLAGS)

all: playdom player testDrawCard testBuyCard badTestDrawCard

clean:
	rm -f *.o playdom.exe playdom test.exe test player player.exe testDrawCard testDrawCard.exe testBuyCard testBuyCard.exe badTestDrawCard badTestDrawCard.exe unittest1 unittest2 unittest3 unittest4 cardtest1 cardtest2 cardtest3 cardtest4 randomtestcard randomtestadventurer testdominion testScoreFor testIsGameOver testWhoseTurn testGetWinners testFindTheWinnerIntegration testInitializeGame testSystem *.out *.gcov *.gcda *.gcno *.so
